package itcast.service.impl;

import itcast.dao.BuildDao;
import itcast.dao.impl.BuildDaoImpl;
import itcast.domain.Build;
import itcast.service.BuildService;

import java.util.List;
import java.util.Map;

public class BuildServiceImpl implements BuildService {
    private BuildDao buildDao=new BuildDaoImpl();
    @Override
    public List<Build> findAll() {
        return buildDao.findAll();
    }

    //添加数据

    @Override
    public void addbuild(Build build) {
        buildDao.add(build);
    }

    //根据id查找数据

    @Override
    public Build findBuildById(String id) {
        return buildDao.findById(Integer.parseInt(id));
    }

    //修改Build数据

    @Override
    public void updateBuild(Build build) {
        buildDao.update(build);
    }

    //根据id删除数据

    @Override
    public void deleteBuild(String id) {
        buildDao.delete(Integer.parseInt(id));
    }

    //删除选中数据

    @Override
    public void delBuildSelected(String[] ids) {

            if(ids!=null &&  ids.length>0){
                //1.遍历数组
                for(String id :ids){
                    //2.调用dao删除
                    buildDao.delete(Integer.parseInt(id));
                }
            }

        }
        //条件查询


    @Override
    public List<Build> findBuildByDate(Map<String, String[]> condition) {
        return buildDao.findByDate(condition);
    }
}
